package m.jclecai.com.pay;

import m.jclecai.com.base.BaseActivity;
import m.jclecai.com.bean.PayChannelBean;
import m.jclecai.com.constant.Constant_Url;
import m.jclecai.com.utils.ChannelUtil;

/**
 * Created by Dinosa on 2017/12/29.
 * <p>
 * 二维码的支付方式；
 */

public class PayWithQrCodePayImpl extends BasePayImpl {

    public String mPayMoney;
    public String mUserId;

    public PayWithQrCodePayImpl(BaseActivity activity, String userId) {
        super(activity);
        mUserId = userId;
    }

    @Override
    public void pay(PayChannelBean channelBean, String payMoney) {
        mPayMoney = payMoney;
        showDialog();
        payWidthQrCode(channelBean);
    }

    //二维码的充值方式
    private void payWidthQrCode(PayChannelBean channelBean) {

        dissDialog();
        String type = "1";

        if (channelBean.getChannel().contains("alipay")
                || channelBean.getLogo().equals("alipay")) {
            type = "1";
        } else if (channelBean.getChannel().contains("qqpay")
                || channelBean.getLogo().equals("qqpay")) {
            type = "2";
        } else if (channelBean.getChannel().contains("wxpay")
                || channelBean.getLogo().equals("wxpay")) {
            type = "3";
        }
        String url = Constant_Url.CP_PAY + "?price=" + mPayMoney + "&pay_id=" + mUserId + "&type=" + type + "&channel=" + channelBean.getChannel() + "&appstore=" + ChannelUtil.getChannel();

        weakUpPay(url,false);
//        if (channelBean.getChannel().contains("alipay")
//                || channelBean.getLogo().equals("alipay")) {
//           weakUpPay(url,false);
//        } else {
//            startActivity(WebHelperActivity.getInstance(mActivity,
//                    url,
//                    false,
//                    channelBean.getName(),
//                    true, true));
//        }
    }
}
